<template>
	<view>
		<view class="" v-for="(item,index) in lists" :key="index" @click="xieyi('消息详情',item.activity_id)">
			<view class="w100 " style="display: flex; justify-content: space-between;">
				<view>
					<image style="width: 50rpx;height: 50rpx;border-radius: 50%;" :src="item.activity_img" mode=""></image>
				</view>
				<view class="w100 ml-15">
					<view class="w100 flex-b">
						<view class="s2 ">
							{{item.activity_title}}
						</view>
						<view class="s1">
							{{times(item.created_at)}}
						</view>
					</view>
					<view class="s2 text-line-2 mt-10" style="height: 80rpx;">
						<u-parse :content='item.activity_content'></u-parse>
					</view>
				</view>
			</view>
			<view class="w100 mt-20 mb-30" style="height: 1rpx;background-color: #313554;"></view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				lists:[]
			}
		},
		onLoad() {
			this.getList()
		},
		
		methods: {
			xieyi(name,id){
				uni.navigateTo({
					url:'/pages/index/xieyi?name='+name+'&id='+id
				})
			},
			times(str){
				let date=new Date( Number(str + '000') )
				const formatNumber = n => {
					n = n.toString()
					return n[1] ? n : '0' + n
				}
				 console.log(str);
				 	 console.log(date);
				const formatTime = (date, word = false, datestring = '/', timestring = ":") => {
					
					const year = date.getFullYear()
					const month = date.getMonth() + 1
					const day = date.getDate()
					const hour = date.getHours()
					const minute = date.getMinutes()
					const second = date.getSeconds()
					// if (word == false) {
					// 	return [year, month, day].map(formatNumber).join(datestring) + ' ' + [hour, minute, second].map(
					// 		formatNumber).join(
					// 		timestring)
					// }
					return [year].map(formatNumber) + '年' + [month].map(formatNumber) + '月' + [day].map(formatNumber) + '日' + ' ' +
						[
							hour
						].map(formatNumber) + ':' + [minute].map(formatNumber) + ':' + [second].map(formatNumber)
				}
				return formatTime(date)
			},
			getList() {
				this.$http.get('user/get_activitys?type=1').then(res => {
					if (res.code == 200) {
						
						this.lists = res.data
						console.log(this.lists,444444);
					} else if (res.msg) {
						uni.$u.toast(res.msg)
					}
				})
			}
		}
	}
</script>

<style>
	page {
		background-color: #1E2240;
		padding: 30rpx 50rpx;
	}

	.text-line-2 {
		display: -webkit-box;
		word-break: break-all;
		/*超出文字用省略号代替*/
		text-overflow: ellipsis;
		/*竖直方向的超出和隐藏*/
		-webkit-box-orient: vertical;
		/*设定行数为2*/
		-webkit-line-clamp: 2;
		/*多出部分隐藏*/
		overflow: hidden;

	}

	.s1 {
		font-size: 24rpx;
		font-weight: 400;
		color: #fff;
	}

	.s2 {
		font-size: 28rpx;
		font-weight: 400;
		color: #fff
	}
</style>